package cn.vic.model;

import cn.vic.config.model.DatabaseElement;
import cn.vic.db.DatabaseFactory;
import cn.vic.db.model.Table;
import cn.vic.db.sql.BaseSqlInterface;

/**
 * Created by vic on 2017/8/9.
 */
public class TableUpdateModel {
    private String schema;
    private String libName;
    private String tableName;
    private String columnName;
    private String columnValue;
    private String type;
    private DatabaseElement databaseElement;
    private BaseSqlInterface baseSql;

    public TableUpdateModel(String libName, String tableName, String columnName, String columnValue) {
        this.libName = libName;
        this.tableName = tableName;
        this.columnName = columnName;
        this.columnValue = columnValue;
        StringBuffer key = new StringBuffer();
    }

    public TableUpdateModel(Table table, DatabaseElement databaseElement) {
        baseSql = DatabaseFactory.getSqlFormat(databaseElement);
        this.libName = table.getCatalog();
        this.schema = table.getSchema();
        this.tableName = table.getTableName();
    }


    public String getSql() {
        return baseSql.getUpdateRemarksSql(this);
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getKey() {
        return new StringBuffer().append(libName).append(".").append(tableName).append(".").append(columnName).toString();
    }


    public String getLibName() {
        return libName;
    }

    public void setLibName(String libName) {
        this.libName = libName;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnValue() {
        return columnValue;
    }

    public void setColumnValue(String columnValue) {
        this.columnValue = columnValue;
    }

    public DatabaseElement getDatabaseElement() {
        return databaseElement;
    }

    public void setDatabaseElement(DatabaseElement databaseElement) {
        this.databaseElement = databaseElement;
    }

    public String getSchema() {
        return schema;
    }

    public void setSchema(String schema) {
        this.schema = schema;
    }
}
